<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>index2</title>
</head>
<style>
  #btn {
    background-color: rgb(37, 221, 37);
    color: #fff;
    border-radius: 6%;
    border: 1px solid rgb(37, 221, 37);
    height: 60px;
    width: 80px;
  }

  #btn1 {
    background-color: rgb(253, 105, 105);
    color: #fff;
    border-radius: 6%;
    border: 1px solid rgb(37, 221, 37);
    height: 60px;
    width: 80px;
  }
</style>

<body>
  <button id='btn'>剁手按钮</button>
  <script>
    const button = document.querySelector('button');

    const payMoney = function () {
      console.log('剁手成功');
      console.log(this);
    };

    function dobounce(fun, time) {
      let timer
      return function () {
        const that = this
        console.log('已点击');
        clearTimeout(timer)
        timer = setTimeout(() => {
          fun.call(that)
        }, time);
      }
    };

    button.addEventListener('click', dobounce(payMoney, 1000))
    // button.addEventListener('click', payMoney)
  </script>
</body>

</html>